package cn.farm.farm.Service.CommonService;

import cn.farm.farm.Config.Common.CommonException.DefaultException;
import cn.farm.farm.Mapper.CommonMapper.CategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;
    public List<String> foundByType(String type, String value) {
        List<String> list = null;
        if(type.equals("kingdom")){
            list = categoryMapper.foundByType1(value);//界
        }else if(type.equals("phylum")){
            list = categoryMapper.foundByType2(value);//门
        }else if (type.equals("class")){
            list = categoryMapper.foundByType3(value);//纲
        }else if(type.equals("bioOrder")){
            list = categoryMapper.foundByType4(value);//目
        }else if(type.equals("family")){
            list = categoryMapper.foundByType5(value);//科
        }else if(type.equals("genus")){
            list = categoryMapper.foundByType6(value);//属
        }
        if(list.isEmpty()){
            throw new DefaultException("未找到任何相关信息");
        }
        return list;
    }
}
